package com.example.carapplication;

import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import com.example.carapplication.pageFragment.HomePageFragment;
import com.example.carapplication.pageFragment.MyFragment;
import com.example.carapplication.pageFragment.NearbyFragment;
import com.example.carapplication.pageFragment.RouteFragment;

import android.os.Bundle;
import android.view.Window;
import android.widget.TabHost.TabSpec;

public class MainActivity extends FragmentActivity {
	FragmentTabHost mTabHost;
	TabSpec tabSpec;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		getWindow();
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		// 初始化FragmentTabHost
		mTabHost = (FragmentTabHost) findViewById(R.id.tabhost);
		mTabHost.setup(this, getSupportFragmentManager(), R.id.id_content);
		initEvents();

	}

	private void initEvents() {
		// TODO Auto-generated method stub
		TabSpec tabSpec = mTabHost.newTabSpec("HomePage").setIndicator("首页");
		mTabHost.addTab(tabSpec, HomePageFragment.class, null);
		tabSpec = mTabHost.newTabSpec("Nearby").setIndicator("附近");
		mTabHost.addTab(tabSpec, NearbyFragment.class, null);
		tabSpec = mTabHost.newTabSpec("Route").setIndicator("路线");
		mTabHost.addTab(tabSpec, RouteFragment.class, null);
		tabSpec = mTabHost.newTabSpec("My").setIndicator("我的");
		mTabHost.addTab(tabSpec, MyFragment.class, null);
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		mTabHost = null;
	}

}
